/*
	Filename	:	BJShoe.cpp
	Author(s)	:	Ray E. Bornert II
	Date		:	2002-JUN-10
	Copyright	:	(c) 2002 RealTimeGaming

	History		:
*/

//////////////
// INCLUDES //
//////////////
#include "lib.h"
#include "bjshoe.h"
#include <string.h>
#include "bjrules.h"


BJShoe::BJShoe(CardMgr*	pMgr, int32 nDecks, const ShueGameInfo &sgi)
:	Shue( pMgr, nDecks, sgi )
{
	SetNoFilter();
}

BJShoe::~BJShoe()
{
}

void
BJShoe::SetNoFilter()
{
	memset( m_isRemoved, 0, sizeof(m_isRemoved) );
}

void
BJShoe::SetRemoved( uint8 card )
{
	m_isRemoved[ card ] = 1;
}

void
BJShoe::SetDeckFilter( __int64 filterBits )
{
	//                          --AKQJ098765432-
	//==========================================
	__int64 allCardsRemoved = 0x00FFFFFFFFFFFFF0;

	if ((filterBits & allCardsRemoved) == allCardsRemoved)
		return;

	SetNoFilter();

	if (filterBits == 0)
		return;

	for ( int i=0; filterBits; filterBits >>= 1, i++ )
	if (filterBits & 1)
	{
		int card = BJRules::CardCode( i );
		SetRemoved( card );
	}
}

int
BJShoe::IsRemoved( uint8 card )
{
	int isRemoved = m_isRemoved[ card ];
	return isRemoved;
}

uint8
BJShoe::getCard()
{
	uint8 card = Shue::getCard();
	while (IsRemoved(card) || card < 18 || card > 78) //RPF 20090422 EXTRA CHECK TO ONLY ALLOW CORRECT CARDS JOKER IS NOT VALID IN BJSHOE
		card = Shue::getCard();

	return card;
}
